<?php

require("connect.inc.php");

class DbHelper 
{
	public static function save($data,$url)
	{
		global $db;
	    $model=$db->edu_article()->insert(array(
				'title'=>$data['title'],
				'summary'=>isset($data["summary"]) ?$data["summary"]: NULL ,
				'content'=>$data['content'],
				'createtime'=>$data['createtime'],
				'parentid'=>5,
				'userid'=>1,
				'views'=>rand(1000,3987),
				'status'=>200,
				'pic'=>$data['pic']
			));
		if($model['id']>0) self::saveurl($url);
	}


	public static function IsFetchUrl($url)
	{
		global $db;
		if ($db->fetchlog()->where('url',$url)->count('id')==0) {
			return true;
		}
		else{
			return false;
		}
	}

	public static function saveurl($url)
	{
		global $db;
		$db->fetchlog()->insert(array(
				'url'=>$url,
			));
	}


	public static function articlelist()
	{
		global $db;
		$list=$db->edu_article();
		return $list;
	}
}